const filter = {
  userNickSplitFun: function(val) {
    if (val) {
      if (val.length > 2) {
        return val.slice(val.length - 2, val.length);
      } else {
        return val;
      }
    } else {
      return "无";
    }
  },
  baseTimeSplitFun: function(val) {
    if (val) {
      if (val.indexOf(" ") > -1) {
        return val.split(" ")[0];
      } else {
        return val;
      }
    } else {
      return "暂无";
    }
  },
  userCompSplitFun: function(val) {
    if (val) {
      if (val.length > 2) {
        return val.slice(0, 2);
      } else {
        return val;
      }
    } else {
      return "无";
    }
  },
  baseTimeFun: function(val) {
    if (val) {
      var standardTime = new Date(Number(val));
      var y, m, d, h, f;
      y = standardTime.getFullYear();
      m = standardTime.getMonth() + 1;
      m = m > 9 ? m : "0" + m;
      d = standardTime.getDate();
      d = d > 9 ? d : "0" + d;
      h = standardTime.getHours();
      h = h > 9 ? h : "0" + h;
      f = standardTime.getMinutes();
      f = f > 9 ? f : "0" + f;
      return y + "-" + m + "-" + d + " " + h + ":" + f;
    } else {
      return "暂无";
    }
  },
  baseGYMDTimeFun: function(val) {
    if (val) {
      var standardTime = new Date(Number(val));
      var y, m, d, h, f;
      y = standardTime.getFullYear();
      m = standardTime.getMonth() + 1;
      m = m > 9 ? m : "0" + m;
      d = standardTime.getDate();
      d = d > 9 ? d : "0" + d;
      h = standardTime.getHours();
      h = h > 9 ? h : "0" + h;
      f = standardTime.getMinutes();
      f = f > 9 ? f : "0" + f;
      return y + "-" + m + "-" + d;
    } else {
      return "暂无";
    }
  },
  baseDateFun: function(val) {
    if (val) {
      var standardTime = new Date(Number(val));
      var y, m, d, h, f;
      y = standardTime.getFullYear();
      m = standardTime.getMonth() + 1;
      m = m > 9 ? m : "0" + m;
      d = standardTime.getDate();
      d = d > 9 ? d : "0" + d;
      h = standardTime.getHours();
      h = h > 9 ? h : "0" + h;
      f = standardTime.getMinutes();
      f = f > 9 ? f : "0" + f;
      return y + "." + m + "." + d;
    } else {
      return "暂无";
    }
  },
  baseStrFun: function(val) {
    if (val) {
      return val;
    } else {
      return "暂无";
    }
  },
  baseCompactStateFun: function(val) {
    if (val) {
      if (val == "waited") {
        return "待审批";
      } else if (val == "agree") {
        return "已同意";
      } else if (val == "refuse") {
        return "已拒绝";
      } else if (val == "revoke") {
        return "已撤消";
      } else if (val == "已转交") {
        return "transfer";
      }
    } else {
      return "暂无";
    }
  }
};
export default filter;
